# RedFire 用户服务 Makefile
# 提供常用的开发和部署命令

.PHONY: help install install-dev update-deps security-scan test lint format clean build run

# 默认目标
help:
	@echo "RedFire 用户服务 - 可用命令:"
	@echo ""
	@echo "📦 依赖管理:"
	@echo "  install      - 安装生产依赖"
	@echo "  install-dev  - 安装开发依赖"
	@echo "  update-deps  - 更新所有依赖文件"
	@echo ""
	@echo "🔒 安全检查:"
	@echo "  security-scan - 运行依赖安全扫描"
	@echo ""
	@echo "🧪 测试与质量:"
	@echo "  test         - 运行测试"
	@echo "  lint         - 代码检查"
	@echo "  format       - 代码格式化"
	@echo ""
	@echo "🚀 应用运行:"
	@echo "  run          - 启动开发服务器"
	@echo "  build        - 构建生产镜像"
	@echo ""
	@echo "🧹 清理:"
	@echo "  clean        - 清理临时文件"

# 依赖管理
install:
	python -m pip install --no-deps -r requirements/production.txt

install-dev:
	python -m pip install --no-deps -r requirements/development.txt

update-deps:
	python scripts/update-deps.py

# 安全检查
security-scan:
	python scripts/security-scan.py

# 测试与代码质量
test:
	python -m pytest tests/ -v --tb=short

lint:
	python -m flake8 .
	python -m mypy .

format:
	python -m black .
	python -m isort .

# 应用运行
run:
	python main.py

run-prod:
	gunicorn main:app --config gunicorn.conf.py

# 构建
build:
	docker build -t redfire-user-service .

# 清理
clean:
	find . -type d -name "__pycache__" -exec rm -rf {} +
	find . -type f -name "*.pyc" -delete
	find . -type f -name "*.pyo" -delete
	find . -type f -name "*.pyd" -delete
	find . -type f -name ".coverage" -delete
	find . -type d -name "*.egg-info" -exec rm -rf {} +
	find . -type d -name ".pytest_cache" -exec rm -rf {} +
	find . -type d -name ".mypy_cache" -exec rm -rf {} +
	rm -rf build/
	rm -rf dist/
	rm -rf security-reports/